<template>
    <div style="background:#f7f6f6;padding: 20px 0px;position: relative;left: 0px;top: 0px;height: 100vh">
    <van-row type="flex" justify="space-around" style='margin: 0px 0px;background: #ffffff'>
    	<van-col span="24">
    	<van-cell-group style='width: 92%;'>
    		 <!-- icon="question"  @click-icon="$toast('question')" -->
            <van-field v-model="name" style='15px 0px' required clearable label="纳税人名称" placeholder="请输入纳税人名称" @blur='showTabbar()' @focus='hiddenTabbar()'/> 
            <van-field v-model="taxNo" style='15px 0px'  clearable  label="纳税人识别号" placeholder="请输入纳税人识别号" @blur='showTabbar()' @focus='hiddenTabbar()'/>
            <van-field v-model="email" style='15px 0px' required clearable  label="收票人邮箱" placeholder="请输入收票人邮箱" required @blur='showTabbar()' @focus='hiddenTabbar()'/>
        </van-cell-group>
        </van-col>
    </van-row>
    <br style="margin:20px 0px">
    <van-row type="flex" justify="space-around" style='margin: 0px 0px;background: #ffffff'>
    	<van-col span="24">
    	   <van-cell-group style='width: 92%;'>
  		    <van-field   disabled  style='15px 0px'      label="销售方"     value="章丘停车运营公司"   />
            <van-field      disabled  style='15px 0px'  label="开票金额"    :value="bills"      />
            </van-cell-group>
        </van-col>
    </van-row>
    <van-tabbar  v-show='tabbarSign'>
            <van-tabbar-item class="unlawful-reporting-item" @click.native='save()'>确认开票</van-tabbar-item>
    </van-tabbar>
  </div>
</template>
<script>
import { Toast } from 'vant';
import { InvoiceService,GuidanceService } from './api';
import {formatMoneyPenny} from './utils';
// let zqOpenId= sessionStorage.getItem('zqOpenId');
export default {
    name: 'ticketEdit',
    data() {
        return {
            tabbarSign:true,
            name:'',
            taxNo:'',
            email:'',
            bills:0,
            zqOpenId:''
        };
    },
    created() {  
    this.bills= formatMoneyPenny(this.$route.params.bills);
    this.zqOpenId=this.$route.params.zqOpenId;
    },
    methods: {
        onChange() {}, 
         save(){
        let saveData={
            accountNos:this.$route.params.accountNos,
            email:this.email,
            name:this.name,
            taxNo:this.taxNo,
            openid:this.zqOpenId
        }

        if(!(saveData.email&&saveData.name)){
            Toast.fail('请输入相关信息！');
            return;

        } if(!(saveData.accountNos&&saveData.accountNos[0])){
            Toast.fail('请选择对应的账单！');
            return;
        }
            InvoiceService.invoice(saveData).then((res) => {                             
                 Toast.success('发票开具中,稍后会发到您邮箱');
            }, (err) => {
                Toast.fail(err.responseJSON.msg);
            });

         
           // Toast.fail('上报失败');
        },
        showTabbar(){
            this.tabbarSign=true;
        },
        hiddenTabbar(){
            this.tabbarSign=false;
        },
    },
};
</script>
<style scoped="">
.van-col--24 {
    width: 85%;
    text-align: center;
}
</style>